package jlts.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @ClassName Server
 * @Description TODO
 * @Author Zxeao
 * @Date 2021/12/23 下午5:09
 * @Version V1.0
 */
public class Server {
    ServerSocket server;

    public Server() {
        try {
            server=new ServerSocket(8080);
            System.out.println("服务器启动成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void start(){
        try {
            while(true){
                Socket client=server.accept();
                System.out.println("客户端"+client.getInetAddress().getHostAddress()+"连接成功");
                ServerThread t=new ServerThread(client);
                t.start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}